package com.falcon.auto;

import com.falcon.config.FileConfig;
import com.falcon.storage.IFileStorage;
import com.falcon.storage.impl.FileDbStorage;
import com.falcon.storage.impl.FileDiskStorage;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * @author zongf
 * @since 2023-05-25
 **/
@Configuration(proxyBeanMethods = false)
@Import(FileConfig.class)
public class FileAutoConfig {

    @Bean
    public IFileStorage fileDiskStorage(FileConfig fileConfig) {
        if (FileConfig.StorageType.MYSQL.equals(fileConfig.getStorageType())) {
            return new FileDbStorage();
        }else {
            return new FileDiskStorage();
        }
    }

}
